package com.gduf.gulimall.product.service.impl;


import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gduf.common.utils.PageUtils;
import com.gduf.common.utils.Query;

import com.gduf.gulimall.product.dao.BrandDao;
import com.gduf.gulimall.product.entity.BrandEntity;
import com.gduf.gulimall.product.service.BrandService;


@Service("brandService")
public class BrandServiceImpl extends ServiceImpl<BrandDao, BrandEntity> implements BrandService {

    @Override
        public PageUtils queryPage(Map<String, Object> params) {
            String key = (String)params.get("key");
            QueryWrapper<BrandEntity> wrapper = new QueryWrapper<>();
            if(!StringUtils.isEmpty(key)){

                wrapper.eq("brand_id",key).or().like("name",key);
            }

            IPage<BrandEntity> page = this.page(
                    new Query<BrandEntity>().getPage(params),
                    wrapper
            );

            return new PageUtils(page);
    }

}